[Nexthop][fboss2-dev] fboss2 config/delete protocol bgp neighbor commands - #1391
[Nexthop][fboss2-dev] fboss2 config/delete protocol bgp neighbor commands#1391hillol-nexthop wants to merge 7 commits into
Conversation
b3655bb to
66df523
Compare
2c550b4 to
e7d07de
Compare
f3e5517 to
0077ebd
Compare
|
@hillol-nexthop has updated the pull request. You must reimport the pull request before landing. |
|
This pull request has been imported. If you are a Meta employee, you can view this in D114376255. (Because this pull request was imported automatically, there will not be any future comments.) |
0077ebd to
4a98e2a
Compare
|
@hillol-nexthop has updated the pull request. You must reimport the pull request before landing. |
1 similar comment
|
@hillol-nexthop has updated the pull request. You must reimport the pull request before landing. |
d0bc5e2 to
0c31624
Compare
|
@hillol-nexthop has updated the pull request. You must reimport the pull request before landing. |
1 similar comment
|
@hillol-nexthop has updated the pull request. You must reimport the pull request before landing. |
01e8ce2 to
256b09f
Compare
|
@hillol-nexthop has updated the pull request. You must reimport the pull request before landing. |
Follow-up cleanups to the BGP-aware config session infra (facebook#1344): - Collapse the BGP_RESTART action level into AGENT_WARMBOOT (bgpd has no hitless reload; its restart already runs the agent-warmboot code path). - Introduce a single ConfigDomain descriptor + configDomains() and shared per-domain helpers so commit(), rollback() and `config session diff` handle the agent and BGP domains uniformly (private DiffDomain removed). - Make the agent skip-when-unchanged like BGP: a commit whose staged config equals what is already promoted is a true no-op (no git revision, no symlink churn, no reloadConfig()/bgpd restart). Change detection is semantic (compare the deserialized thrift structs), so formatting-only diffs don't count. - Consolidate `config session clear` onto a static stagedSessionFilePaths() and reuse ConfigSession::readStagedContent() in diff. - Make ConfigSession::saveConfig(service, level) generic over the service and reduce saveBgpConfig() to a thin wrapper. - Keep the heavy generated thrift headers out of ConfigSession.h: use the *_types_fwd.h forward-declaration headers, hold agentConfig_/bgpConfig_ by std::unique_ptr, and drop the configLoaded_/bgpConfigLoaded_ bools (null == not loaded). - clang-tidy: use auto for the SimpleJSONSerializer template-cast results. Built fboss2-dev + the config unit tests; config-session/commit/diff/BGP/clear tests pass. Verified the agent no-op behaviour live on test switches.
Removed comments about the destructor definition in ConfigSession.h.
…thInterface call main renamed findFirstEthInterface() to getRandomInterfacePortName() (virtual-management-port fix); convert the branch-added no-op-commit test to the new helper. Drop the three includes ConfigSession.cpp no longer uses directly (misc-include-cleaner runs as errors in CI).
256b09f to
1b66afd
Compare
|
@hillol-nexthop has updated the pull request. You must reimport the pull request before landing. |
Add `fboss2-dev config protocol bgp global <attr> <value>` on top of the BGP-aware ConfigSession (base PR). Edits the typed bgp::thrift::BgpConfig via ConfigSession::getBgpConfig()/saveBgpConfig() -- the whole-config, scope-agnostic typed API (no global/peer/peer-group special-casing in ConfigSession). - Collapse the 10 per-attribute global command classes into one dispatcher; reject cluster-id (no BgpConfig field) instead of writing dead config; bound switch-limit / max_golden_vips so out-of-range values aren't truncated. - Integration tests: ConfigBgpGlobalTest (each attr set+commit, verified in the promoted /etc/coop/bgpcpp/bgpcpp.conf) and ConfigBgpSessionTest (clear/diff/commit/rollback + a no-op-restart regression), sharing ConfigBgpTestBase. Test Plan: - bazel test //fboss/cli/fboss2/test/config:cmd_config_test - bazel build //fboss/cli/fboss2/test/integration_test:fboss2_integration_test - fboss2_integration_test on a DUT with bgp_pp active: ConfigBgpSessionTest 6/6 pass (clear, diff, commit-restarts-bgp_pp, rollback-restores-config, and the unchanged-config does-not-restart case); agent-session regression (ConfigInterfaceMtuTest) passes.
- Extract the value parsers (parseBool/parseInt/parseNonNegInt32, handler Result) into a shared BgpCliValueParsers.h so sibling BGP dispatchers can reuse them, and add a bounded parseAsn4Byte: local-asn/confed-asn accepted any uint64 and silently persisted out-of-range ASNs (>= 2^32 wrap the i64 field negative). - positionals_at_end() on the global command: CLI11's parent-chain subcommand fallthrough steals value tokens that match a sibling command name (e.g. a policy named "peer-group") and misparses the command. - Integration test base: probe the bgpd unit, and pass -c safe.directory=/etc/coop on the raw git invocations (gitHead / bgpTrackedAtRevision), mirroring the CLI's Git class -- /etc/coop is owned by another user (e.g. coop) on provisioned devices, which git otherwise rejects as dubious ownership and the helpers silently return empty results.
The commit-path global-attribute tests asserted on the promoted /etc/coop/bgpcpp/bgpcpp.conf, which only proves what the CLI wrote to disk. Route ConfigBgpTestBase::setAndCommit() through a new readRunningBgpConfigViaRpc() -- TBgpService::getRunningConfig against the local bgpd -- so every positive ConfigBgpGlobalTest asserts its attribute in the daemon's own view of its config, proving bgpd parsed and adopted the promoted file after the commit-triggered restart. The helper retries briefly on connection errors: systemd reports bgpd active as soon as the process starts, but its thrift server binds the port a few seconds later, so an RPC issued right after a restart races that window. Test Plan: - bazel build //fboss/cli/fboss2/test/integration_test:fboss2_integration_test - fboss2_integration_test on a DUT with bgpd active: ConfigBgpGlobalTest 7/7 pass (each attribute set+commit verified in bgpd's getRunningConfig view, plus the invalid-bool and negative-graceful-restart-time reject paths).
1b66afd to
e876f28
Compare
|
@hillol-nexthop has updated the pull request. You must reimport the pull request before landing. |
Adds `config protocol bgp neighbor <ip-address> [<attribute> <value> ...]` and `delete protocol bgp neighbor <ip-address>` — the first per-peer BGP config family, beneath the `protocol bgp` grouping node. - neighbor dispatcher keyed by peer address, writing bgp_config.BgpPeer through the typed ConfigSession. Attributes cover the peer identity (remote/local ASN, description, peer-tag, peer-group), policy bindings (ingress/egress policy), session tunables (timers, route limits, next-hop, add-path, RR client, and the rest of the documented set), and the sheet-documented attributes bgpd does not support, which are rejected with an explanatory message rather than staged. - delete removes the peer by address. - ConfigBgpTestBase restores the committed BGP config after every test, so a failed run cannot leave a device carrying test config; commit-path integration tests verify each value through bgpd's own getRunningConfig RPC rather than only the staged file. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
e876f28 to
108f8a1
Compare
|
@hillol-nexthop has updated the pull request. You must reimport the pull request before landing. |
Summary
Adds
fboss2-dev config protocol bgp neighbor <ip-address> [<attribute> <value> ...]as a single dispatcher mirroring theglobalcommand: the neighbor address is the first positional token, one- or two-token attributes (timers hold-time,add-path send, ...) are matched longest-prefix-first, and handlers mutate the typedbgp::thrift::BgpPeerviaConfigSession::getBgpConfig()/saveBgpConfig(). Also addsfboss2-dev delete protocol bgp neighbor <ip-address>. The 26 old per-attributepeercommand classes and the now-dead per-peerfolly::dynamic BgpConfigSessionAPI are deleted.BgpPeerfieldremote-asn/local-asnremote_as_4_byte/local_as_4_byte(4-byte-bounded)description,peer-tag,peer-group,peer-id,typedescription,peer_tag,peer_group_name,peer_id,typeingress-policy/egress-policyingress_policy_name/egress_policy_namerr-client,confed-peer,redistribute-peer,enhanced-route-refresh,next-hop-selfconnect-mode <PASSIVE|ACTIVE>is_passiveafi disable-ipv4-afi/disable-ipv6-afi/ipv4-over-ipv6-nhdisable_ipv4_afi/disable_ipv6_afi/v4_over_v6_nexthopadd-path send|receive <bool>AddPathenum (RECEIVE/SEND/BOTH)bind-addr address,next-hop4,next-hop6local_addr,next_hop4,next_hop6(IP/family-validated)graceful-restart restart-time/stateful-habgp_peer_timers.graceful_restart_seconds/enable_stateful_hatimers hold-time/keepalive/out-delay/withdraw-unprog-delaybgp_peer_timers.*max-route pre-filter/post-filter/{pre,post}-warning-threshold/{pre,post}-warning-onlypre_filter/post_filterRouteLimit fieldslink-bandwidth,advertise-lbw,receive-lbwlink_bandwidth_bps,advertise_link_bandwidth,receive_link_bandwidth(enum-membership-validated)Bare
neighbor <ip>creates the peer; attribute sets find-or-create it, keyed by thefolly::IPAddress-normalizedpeer_addr(prefix notation for passive sessions accepted).delete protocol bgp neighbor <ip>removes the matching peer via the same shared normalize/find helpers (BgpPeerAddr.h); deleting an unknown neighbor errors without persisting anything.Behavior notes
local_addr/next_hop4/next_hop6=0.0.0.0/::): bgpd constructsfolly::IPAddressfrom these non-optional fields at config load and aborts on the empty strings a fresh peer would otherwise serialize (IPAddressFormatExceptioninConfig::createCommonPeerGroupConfig, reproduced on a test device — the daemon crash-looped into systemd's start limit). The pre-existing sparse-JSON path had the same latent bug.cluster-idin the global PR):connect-mode BOTH(thrift only modelsis_passive),peer-port/bind-addr port(no per-peer port field; the daemon uses the globallisten_port),afi ipv4/ipv6-labeled-unicast(no thrift field). A rejected value never lands on disk.neighbor <ip> peer-group Xmisparsed withXas the neighbor address).positionals_at_end()on the neighbor command makes everything after the first positional parse as positionals.bgp_json_to_cli.pypeer generators emit the newneighborgrammar (shlex-escaped, including the neighbor address; the shell-injection test is updated accordingly); explicit zero timers/limits are no longer dropped and symbolicadd_pathenum names are handled.TBgpService::getRunningConfigRPC (with a brief connection retry — systemd reports the unit active before the thrift server binds its port), proving bgpd parsed and adopted the promoted config rather than only checking the file the CLI wrote.Test Plan
Unit —
bazel test //fboss/cli/...:CmdConfigBgpNeighborTestFixture(14 tests: arg validation/normalization, longest-prefix match, add-path merge matrix, connect-mode, parity attributes, ASN/IP/enum validation, reject paths) andCmdDeleteBgpNeighborTestFixture(5 tests).pytest fboss/cli/fboss2/tools/tests/test_bgp_json_to_cli.py(67 pass, including the shell-injection test against the new grammar).Integration on device (real
bgpd_cppdaemon):Sample usage: